package shoppingAnalysis;

import org.apache.hadoop.mapreduce.Partitioner;

public class MyPartitioner3<K, V> extends Partitioner<K, V> {
	@Override
	// 自定义partition的数量需要和reduce
	// task数量保持一致，在setNumReduceTasks是数量填为34，全国34个省份
	public int getPartition(K key, V value, int numPartitions) {
		String province = key.toString();
		if (province.equals("安徽")) {
			return 0;
		} else if (province.equals("澳门")) {
			return 1;
		} else if (province.equals("北京市")) {
			return 2;
		} else if (province.equals("福建")) {
			return 3;
		} else if (province.equals("甘肃")) {
			return 4;
		} else if (province.equals("广东")) {
			return 5;
		} else if (province.equals("广西")) {
			return 6;
		} else if (province.equals("贵州")) {
			return 7;
		} else if (province.equals("海南")) {
			return 8;
		} else if (province.equals("河北")) {
			return 9;
		} else if (province.equals("河南")) {
			return 10;
		} else if (province.equals("黑龙江")) {
			return 11;
		} else if (province.equals("湖北")) {
			return 12;
		} else if (province.equals("湖南")) {
			return 13;
		} else if (province.equals("吉林")) {
			return 14;
		} else if (province.equals("江苏")) {
			return 15;
		} else if (province.equals("江西")) {
			return 16;
		} else if (province.equals("辽宁")) {
			return 17;
		} else if (province.equals("内蒙古")) {
			return 18;
		} else if (province.equals("宁夏")) {
			return 19;
		} else if (province.equals("青海")) {
			return 20;
		} else if (province.equals("山东")) {
			return 21;
		} else if (province.equals("山西")) {
			return 22;
		} else if (province.equals("陕西")) {
			return 23;
		} else if (province.equals("上海市")) {
			return 24;
		} else if (province.equals("四川")) {
			return 25;
		} else if (province.equals("台湾")) {
			return 26;
		} else if (province.equals("天津市")) {
			return 27;
		} else if (province.equals("西藏")) {
			return 28;
		} else if (province.equals("香港")) {
			return 29;
		} else if (province.equals("新疆")) {
			return 30;
		} else if (province.equals("云南")) {
			return 31;
		} else if (province.equals("浙江")) {
			return 32;
		} else {
			return 33;
		}

	}
}
